package com.zbkj.front.model.req;

import com.zbkj.dal.base.constants.RegularConstants;
import com.zbkj.service.model.dto.express.OrderAddressUpdateDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@Data
public class OrderAddressModifyReq {

    @ApiModelProperty(value = "订单地址信息 ID")
    private Integer id;

    @ApiModelProperty(value = "收货人姓名", required = true)
    @NotBlank(message = "收货人姓名不能为空")
    @Length(max = 64, message = "Consignee name cannot exceed 64 characters")
    private String realName;

    @ApiModelProperty(value = "收货人电话")
    @NotBlank(message = "收货人电话不能为空")
    @Pattern(regexp = RegularConstants.PHONE_TWO, message = "请输入正确的手机号")
    private String phone;

    @ApiModelProperty(value = "省份ID")
    @NotNull(message = "省份ID不能为空")
    private Integer provinceId;

    @ApiModelProperty(value = "收货人所在省")
    @NotBlank(message = "收货人所在省不能为空")
    private String province;

    @ApiModelProperty(value = "城市id")
    @NotNull(message = "城市id不能为空")
    private Integer cityId;

    @ApiModelProperty(value = "收货人所在市")
    @NotBlank(message = "收货人所在市不能为空")
    private String city;

    @ApiModelProperty(value = "区/县id")
    @NotNull(message = "区/县id不能为空")
    private Integer districtId;

    @ApiModelProperty(value = "收货人所在区/县")
    @NotBlank(message = "收货人所在区/县不能为空")
    private String district;

    @ApiModelProperty(value = "收货人详细地址", required = true)
    @NotBlank(message = "收货人详细地址不能为空")
    @Length(max = 500, message = "Consignee's full address cannot exceed 500 characters")
    private String detail;


    public OrderAddressUpdateDTO convert() {
        OrderAddressUpdateDTO orderAddressUpdateDTO = new OrderAddressUpdateDTO();
        orderAddressUpdateDTO.setId(id);
        orderAddressUpdateDTO.setRealName(realName);
        orderAddressUpdateDTO.setPhone(phone);
        orderAddressUpdateDTO.setProvinceId(provinceId);
        orderAddressUpdateDTO.setProvince(province);
        orderAddressUpdateDTO.setCityId(cityId);
        orderAddressUpdateDTO.setCity(city);
        orderAddressUpdateDTO.setDistrictId(districtId);
        orderAddressUpdateDTO.setDistrict(district);
        orderAddressUpdateDTO.setDetail(detail);
        return orderAddressUpdateDTO;
    }
}
